@tailwind base;
@tailwind components;
@tailwind utilities;

/* 自定义国风样式 */
@layer base {
  body {
    font-family: 'Noto Serif SC', 'SimSun', serif;
    background: linear-gradient(135deg, #f8f4e8 0%, #f2ecd8 100%);
    min-height: 100vh;
  }
  
  /* 水墨效果 */
  .ink-effect {
    position: relative;
    overflow: hidden;
  }
  
  .ink-effect::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0,0,0,0.1) 0%, transparent 70%);
    animation: ink-flow 8s ease-in-out infinite;
    pointer-events: none;
  }
  
  @keyframes ink-flow {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-30%, -60%) rotate(90deg); }
    50% { transform: translate(-70%, -40%) rotate(180deg); }
    75% { transform: translate(-40%, -70%) rotate(270deg); }
  }

  @keyframes float {
    0%, 100% {
      transform: translateY(0px) translateX(0px) rotate(0deg);
    }
    25% {
      transform: translateY(-20px) translateX(10px) rotate(90deg);
    }
    50% {
      transform: translateY(-10px) translateX(-5px) rotate(180deg);
    }
    75% {
      transform: translateY(-15px) translateX(15px) rotate(270deg);
    }
  }
}

@layer components {
  /* 宣纸效果 */
  .paper-texture {
    background-image:
      radial-gradient(circle at 20% 50%, rgba(120, 119, 108, 0.1) 0%, transparent 50%),
      radial-gradient(circle at 80% 20%, rgba(120, 119, 108, 0.1) 0%, transparent 50%),
      radial-gradient(circle at 40% 80%, rgba(120, 119, 108, 0.1) 0%, transparent 50%);
    background-size: 100px 100px, 80px 80px, 120px 120px;
  }

  /* 径向渐变工具类 */
  .bg-gradient-radial {
    background: radial-gradient(circle, var(--tw-gradient-from), var(--tw-gradient-to));
  }
  
  /* 古风按钮 */
  .ancient-button {
    @apply relative px-8 py-3 bg-gradient-to-r from-gold-400 to-gold-500 text-ink-800 font-medium rounded-lg shadow-lg transition-all duration-300 hover:from-gold-500 hover:to-gold-600 hover:shadow-xl transform hover:-translate-y-1 hover:scale-105;
    border: 2px solid rgba(217, 119, 6, 0.3);
    background-size: 200% 100%;
    transition: all 0.3s ease, background-position 0.3s ease;
  }

  .ancient-button:hover {
    background-position: 100% 0;
    box-shadow: 0 10px 25px rgba(217, 119, 6, 0.3);
  }
  
  .ancient-button::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #d97706, #f59e0b, #d97706);
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .ancient-button:hover::before {
    opacity: 1;
  }
  
  /* 古风输入框 */
  .ancient-input {
    @apply w-full p-6 bg-paper-100 border-2 border-ink-200 rounded-lg shadow-inner text-ink-800 placeholder-ink-400 focus:border-gold-400 focus:ring-2 focus:ring-gold-200 focus:outline-none transition-all duration-300;
    background-image:
      linear-gradient(90deg, rgba(0,0,0,0.02) 1px, transparent 1px),
      linear-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
  }

  .ancient-input:focus {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.15), inset 0 2px 4px rgba(0,0,0,0.1);
  }

  .ancient-input::placeholder {
    transition: all 0.3s ease;
  }

  .ancient-input:focus::placeholder {
    opacity: 0.7;
    transform: translateY(-2px);
  }
  
  /* 诗句展示区域 */
  .poem-display {
    @apply bg-paper-50 border-2 border-ink-200 rounded-lg p-8 shadow-lg paper-texture;
    background-blend-mode: multiply;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
  }

  .poem-display::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(245, 158, 11, 0.1), transparent);
    transform: rotate(-45deg);
    transition: transform 0.6s ease;
    opacity: 0;
  }

  .poem-display:hover::before {
    transform: rotate(-45deg) translateX(100%);
    opacity: 1;
  }

  .poem-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.1);
  }
}

/* 抽卡效果样式 */
@layer utilities {
  /* 3D透视效果 */
  .perspective-1000 {
    perspective: 1000px;
  }

  .transform-style-preserve-3d {
    transform-style: preserve-3d;
  }

  .backface-hidden {
    backface-visibility: hidden;
  }

  .rotate-y-180 {
    transform: rotateY(180deg);
  }

  /* 边框光效动画 */
  @keyframes borderGlow {
    0%, 100% {
      opacity: 0.5;
      transform: rotate(0deg);
    }
    50% {
      opacity: 1;
      transform: rotate(180deg);
    }
  }

  /* 抽卡翻转动画 */
  @keyframes cardFlip {
    0% {
      transform: rotateY(0deg) scale(1);
    }
    50% {
      transform: rotateY(90deg) scale(1.1);
    }
    100% {
      transform: rotateY(180deg) scale(1);
    }
  }

  /* 稀有度光效 */
  @keyframes rarityGlow {
    0%, 100% {
      box-shadow: 0 0 20px currentColor;
    }
    50% {
      box-shadow: 0 0 40px currentColor, 0 0 60px currentColor;
    }
  }

  /* 粒子飞散效果 */
  @keyframes particleFloat {
    0% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
    100% {
      opacity: 0;
      transform: translateY(-100px) scale(0);
    }
  }

  /* 文字逐行显示 */
  @keyframes textReveal {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* 古风艺术字体样式 */
@layer utilities {
  /* 导入中文字体 */
  @import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap');
  @import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&display=swap');

  /* 古风字体类 */
  .font-ancient {
    font-family: 'Ma Shan Zheng', 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', serif;
    font-weight: 400;
    letter-spacing: 0.1em;
    line-height: 1.8;
  }

  .font-calligraphy {
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', 'SimSun', '宋体', serif;
    font-weight: 500;
    letter-spacing: 0.15em;
    line-height: 2;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
  }

  .font-seal {
    font-family: 'Ma Shan Zheng', 'STXinwei', '华文新魏', 'FangSong', '仿宋', serif;
    font-weight: 600;
    letter-spacing: 0.2em;
    line-height: 1.6;
  }

  /* 诗词专用字体效果 */
  .poem-text {
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', serif;
    font-weight: 400;
    letter-spacing: 0.12em;
    line-height: 2.2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: #2c3e50;
    position: relative;
  }

  .poem-text::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 49%, rgba(139, 92, 246, 0.1) 50%, transparent 51%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .poem-text:hover::before {
    opacity: 1;
  }

  /* 古风标题效果 */
  .ancient-title {
    font-family: 'Ma Shan Zheng', 'STXinwei', '华文新魏', serif;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-align: center;
    background: linear-gradient(45deg, #8b5cf6, #ec4899, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    position: relative;
  }

  .ancient-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
  }

  /* 印章效果 */
  .seal-effect {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(45deg, #dc2626, #b91c1c);
    color: white;
    font-family: 'Ma Shan Zheng', 'STXinwei', serif;
    font-weight: 600;
    letter-spacing: 0.2em;
    border-radius: 4px;
    box-shadow:
      inset 0 0 0 2px rgba(255,255,255,0.3),
      0 4px 8px rgba(220,38,38,0.3);
    position: relative;
    overflow: hidden;
  }

  .seal-effect::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 2px;
  }

  /* 毛笔字效果 */
  .brush-text {
    font-family: 'Ma Shan Zheng', 'KaiTi', '楷体', serif;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: #1f2937;
    text-shadow:
      1px 1px 0 rgba(0,0,0,0.1),
      2px 2px 0 rgba(0,0,0,0.05),
      3px 3px 0 rgba(0,0,0,0.02);
    position: relative;
  }

  .brush-text::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-opacity='0.03'%3E%3Cpath d='M20 20h60v60H20z'/%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.5;
  }

  /* 竖排文字效果 */
  .vertical-text {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', serif;
    letter-spacing: 0.1em;
    line-height: 2;
  }

  /* 古风卡片文字 */
  .card-ancient-text {
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', serif;
    font-weight: 500;
    letter-spacing: 0.15em;
    line-height: 2;
    color: #374151;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    position: relative;
  }

  /* 背景叠加诗句样式 */
  .poem-overlay {
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', serif;
    font-weight: 500;
    letter-spacing: 0.15em;
    line-height: 1.8;
    text-shadow:
      2px 2px 8px rgba(0,0,0,0.9),
      0 0 20px rgba(0,0,0,0.7),
      0 0 40px rgba(0,0,0,0.5);
    color: #ffffff;
    position: relative;
    backdrop-filter: blur(1px);
  }

  .poem-overlay::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: radial-gradient(
      ellipse at center,
      rgba(0,0,0,0.3) 0%,
      rgba(0,0,0,0.1) 50%,
      transparent 80%
    );
    border-radius: 20px;
    z-index: -1;
    pointer-events: none;
  }

  /* 情绪标签背景叠加样式 */
  .emotion-overlay {
    background: linear-gradient(
      135deg,
      rgba(0,0,0,0.4) 0%,
      rgba(0,0,0,0.2) 100%
    );
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow:
      0 8px 32px rgba(0,0,0,0.3),
      inset 0 1px 0 rgba(255,255,255,0.1);
  }

  /* 响应式字体大小 */
  @media (max-width: 768px) {
    .poem-text {
      font-size: 0.9em;
      letter-spacing: 0.08em;
      line-height: 2;
    }

    .poem-overlay {
      font-size: 0.8em;
      letter-spacing: 0.1em;
      line-height: 1.6;
      text-shadow:
        1px 1px 6px rgba(0,0,0,0.9),
        0 0 15px rgba(0,0,0,0.7);
    }
  }

  /* 诗句叠加层动画 */
  @keyframes poemFadeIn {
    0% {
      opacity: 0;
      transform: translateY(30px) scale(0.95);
      filter: blur(5px);
    }
    100% {
      opacity: 1;
      transform: translateY(0) scale(1);
      filter: blur(0);
    }
  }

  @keyframes emotionSlideUp {
    0% {
      opacity: 0;
      transform: translateY(20px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-poem-fade-in {
    animation: poemFadeIn 1.2s ease-out forwards;
  }

  .animate-emotion-slide-up {
    animation: emotionSlideUp 0.8s ease-out 0.6s forwards;
    opacity: 0;
  }

  /* 移动端响应式样式 */
  @media (max-width: 768px) {
    .ancient-title {
      font-size: 1.2em;
      letter-spacing: 0.2em;
    }

    .card-ancient-text {
      font-size: 0.85em;
      letter-spacing: 0.1em;
    }
  }

  /* 背景叠加诗句样式 */
  .poem-overlay {
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', serif;
    font-weight: 500;
    letter-spacing: 0.15em;
    line-height: 1.6;
    text-shadow:
      2px 2px 8px rgba(0,0,0,0.9),
      0 0 20px rgba(0,0,0,0.7),
      0 0 40px rgba(0,0,0,0.5);
    color: #ffffff;
    position: relative;
    backdrop-filter: blur(1px);
    margin-bottom: 0.8em;
  }

  .poem-overlay::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: radial-gradient(
      ellipse at center,
      rgba(0,0,0,0.3) 0%,
      rgba(0,0,0,0.1) 50%,
      transparent 80%
    );
    border-radius: 20px;
    z-index: -1;
    pointer-events: none;
  }

  /* 情绪标签背景叠加样式 */
  .emotion-overlay {
    background: linear-gradient(
      135deg,
      rgba(0,0,0,0.4) 0%,
      rgba(0,0,0,0.2) 100%
    );
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow:
      0 8px 32px rgba(0,0,0,0.3),
      inset 0 1px 0 rgba(255,255,255,0.1);
  }

  /* 情绪文字背景样式 */
  .emotion-text-bg {
    background: linear-gradient(
      135deg,
      rgba(255,255,255,0.15) 0%,
      rgba(255,255,255,0.08) 100%
    );
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow:
      0 4px 16px rgba(0,0,0,0.2),
      inset 0 1px 0 rgba(255,255,255,0.2);
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', serif;
    text-shadow:
      1px 1px 3px rgba(0,0,0,0.8),
      0 0 10px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
  }

  .emotion-text-bg:hover {
    background: linear-gradient(
      135deg,
      rgba(255,255,255,0.2) 0%,
      rgba(255,255,255,0.12) 100%
    );
    transform: translateY(-1px);
    box-shadow:
      0 6px 20px rgba(0,0,0,0.25),
      inset 0 1px 0 rgba(255,255,255,0.25);
  }

  /* 诗句叠加层动画 */
  @keyframes poemFadeIn {
    0% {
      opacity: 0;
      transform: translateY(30px) scale(0.95);
      filter: blur(5px);
    }
    100% {
      opacity: 1;
      transform: translateY(0) scale(1);
      filter: blur(0);
    }
  }

  @keyframes emotionSlideUp {
    0% {
      opacity: 0;
      transform: translateY(20px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-poem-fade-in {
    animation: poemFadeIn 1.2s ease-out forwards;
  }

  .animate-emotion-slide-up {
    animation: emotionSlideUp 0.8s ease-out 0.6s forwards;
    opacity: 0;
  }

  /* 简单的情绪文字样式 - 无背景 */
  .emotion-text-simple {
    font-family: 'Noto Serif SC', 'KaiTi', '楷体', 'STKaiti', serif;
    text-shadow:
      1px 1px 3px rgba(0,0,0,0.8),
      0 0 10px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
  }

  /* 响应式样式 */
  @media (max-width: 768px) {
    .poem-overlay {
      font-size: 0.8em;
      letter-spacing: 0.1em;
      line-height: 1.6;
      text-shadow:
        1px 1px 6px rgba(0,0,0,0.9),
        0 0 15px rgba(0,0,0,0.7);
    }
  }
}
